<!DOCTYPE html>
<html lang="en">
<head>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width,initial-scale=1">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>美叮后台管理系统</title>
        <style>
            *{margin: 0; padding: 0}
        </style>
    </head>
</head>
<body>
</body>
</html>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>
    let currentUrl = window.location.href;
    if(currentUrl.indexOf("code=") != -1){
        let str1=currentUrl.split('code=');
        let str2=str1[1].split('&');
        let code = str2[0];
        $.ajax({
            url: 'https://clound.mayding.cn/api/admin/wxLogin',
            type: "POST", // 请求方式
            data: {code:code},
            dataType: "json", // 服务器响应的数据类型
            success: function (res) {
              if(res.data.code == 3){
                  localStorage.setItem('openID', JSON.stringify(res.data.data));
                $.ajax({
                  url:'https://clound.mayding.cn/api/admin/adminUrl',
                  type:'POST',
                  dataType: "json", // 服务器响应的数据类型
                  success: function (ress) {
                    window.location.href = ress.data + '/#/bindAccount';
                  }
                })
              }else{
                localStorage.setItem('id', JSON.stringify(res.data.id));
                localStorage.setItem('name', JSON.stringify(res.data.name));
                localStorage.setItem('token', JSON.stringify(res.data.token));
                localStorage.setItem('isAdmin', JSON.stringify(res.data.is_admin));
                if(res.data.is_admin == "0"){
                  $.ajax({
                    url:'https://clound.mayding.cn/api/admin/adminUrl',
                    type:'POST',
                    dataType: "json", // 服务器响应的数据类型
                    success: function (ress) {
                      window.location.href = ress.data + '/#/homePage';
                    }
                  })
                }else{
                  $.ajax({
                    url:'https://clound.mayding.cn/api/admin/adminUrl',
                    type:'POST',
                    dataType: "json", // 服务器响应的数据类型
                    success: function (ress) {
                      window.location.href = ress.data + '/#/adminHomePage';
                    }
                  })
                }
              }
            }
        })
    }else{
       window.alert('登陆失败，请稍后再试')
    }
</script>
